<!DOCTYPE html>
<div>
    <head>
        <title>(贵州容百)一配-环境除铁记录表</title>
        <!--
        <meta name="viewport" content="width=device-width, initial-scale=1.0 Access-Control-Allow-Origin">
        -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <!-- 引入 Bootstrap -->
        <!--<link href="<?=base_url('html/bootstrap_v3/css/bootstrap.css')?>" rel="stylesheet">-->
        <link href="<?=  base_url('/html/bootstrap_v3/css/bootstrap.css')?>" rel="stylesheet">
        <link href="<?=base_url('html/bootstrap_v3/datepicker/css/bootstrap-datetimepicker.min.css')?>" rel="stylesheet">
        <script src="<?=base_url('html/js/jquery-1.8.3.min.js')?>"></script>
        <script src="<?=base_url('html/bootstrap_v3/js/bootstrap.min.js')?>"></script>
        <script src="<?=base_url('html/bootstrap_v3/datepicker/js/bootstrap-datetimepicker.js')?>"></script>
        <script src="<?=base_url('html/bootstrap_v3/datepicker/js/locales/bootstrap-datetimepicker.zh-CN.js')?>"></script>
        <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
        <script>
            /*
             * 注意：
             * 1. 所有的JS接口只能在公众号绑定的域名下调用，公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
             * 2. 如果发现在 Android 不能分享自定义内容，请到官网下载最新的包覆盖安装，Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
             * 3. 常见问题及完整 JS-SDK 文档地址：http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
             *
             * 开发中遇到问题详见文档“附录5-常见错误及解决办法”解决，如仍未能解决可通过以下渠道反馈：
             * 邮箱地址：weixin-open@qq.com
             * 邮件主题：【微信JS-SDK反馈】具体问题
             * 邮件内容说明：用简明的语言描述问题所在，并交代清楚遇到该问题的场景，可附上截屏图片，微信团队会尽快处理你的反馈。
             */
            wx.config({
                debug: false,
                appId: '<?=$appId;?>',
                timestamp: <?=$timestamp;?>,
                nonceStr: '<?=$nonceStr;?>',
                signature: '<?=$signature;?>',
                jsApiList: [
                    // 所有要调用的 API 都要加到这个列表中
                    'scanQRCode',
                    'chooseImage',
                    'previewImage',
                    'uploadImage',
                    'downloadImage',
                ]
            });
            wx.ready(function () {
                // 在这里调用 API
                document.querySelector('#test').onclick = function () {
                    wx.scanQRCode({
                        needResult: 1,
                        desc: 'scanQRCode desc',
                        success: function (res) {
                            //alert(JSON.stringify(res));
                            var result = res.resultStr;
                            alert(result);
                        }
                    });
                };
                var images = {
                    localId: [],
                    serverId: []
                };
                document.querySelector('#choose').onclick = function(){
                    wx.chooseImage({
                        success: function (res) {
                            /*
                            if(res.localIds.length > 1){
                                alert("只能选择一张图片",null);
                                return;
                            }
                            */
                            images.localId = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
                            alert('已选择 ' + res.localIds.length + ' 张图片');

                            if (images.localId.length == 0) {
                                alert('请先选择要上传的图片');
                                return;
                            }
                            var i = 0, length = images.localId.length;
                            images.serverId = [];
                            function upload() {
                                wx.uploadImage({
                                    localId: images.localId[i],
                                    success: function (res) {
                                        i++;
                                        alert('已上传：' + i + '/' + length);
                                        images.serverId.push(res.serverId);
                                        $.ajax({
                                            type:"GET",
                                            isShowProgressTips: 1, // 默认为1，显示进度提示
                                            url:"<?=base_url()?>/createFile/downloadfile?mediaid="+res.serverId,
                                            success:function(data){
                                                var html = "<img src='<?=base_url()?>/"+data+"' width='320px'>"
                                                //alert(html);
                                                $("#showimg").append(html);
                                            },
                                            error:function(msg){

                                            }
                                        })
                                        if (i < length) {
                                            upload();
                                        }
                                        if(i==length){
                                            //alert(images.serverId);
                                        }
                                    },
                                    fail: function (res) {
                                        alert(JSON.stringify(res));
                                    }
                                });
                            }
                            upload();
                        }
                    });
                }


            });

            $(document).ready(function () {
                $("input[name=temperature]").blur(function () {
                    if(isNaN($(this).val())){
                        alert("露点温度请输入数字！");
                        $(this).val("");
                    }
                });
                $("#submit").click(function(){
                    NoClick();
                    var userName = $("#userName").val();
                    var userId = $("#userId").val();
                    // var userDeptName = $("#userDeptName option:selected").val();
                    var createTime = $("#createTime").val();
                    var productLine = $("#productLine option:selected").val();

                    var classes = $("#classes input:checked").val();
                    var isGroundRemoveIron = $("#isGroundRemoveIron input:checked").val();
                    var isCornernRemoveIron = $("#isCornernRemoveIron input:checked").val();
                    var isToolCaseRemoveIron = $("#isToolCaseRemoveIron input:checked").val();
                    // var isCarryToolRemoveIron = $("#isCarryToolRemoveIron input:checked").val();
                    var isOperatingPlatformRemoveIron = $("#isOperatingPlatformRemoveIron input:checked").val();
                    var isOtherRemoveIron = $("#isOtherRemoveIron input:checked").val();

                    // var envRemoveIronImgSrc = $("#envRemoveIronImgSrc").val();

                    var msg = "";
                    msg = msg + isFillIn(userName,"填写人");
                    // msg = msg + isFillIn(userDeptName,"所在部门");
                    msg = msg + isFillIn(productLine,"生产线名称");

                    msg = msg + isChose(classes,"班次");
                    msg = msg + isChose(isGroundRemoveIron,"地面、墙角、墙边是否除铁");
                    // msg = msg + isChose(isCornernRemoveIron,"墙角、墙边除铁确认");
                    msg = msg + isChose(isToolCaseRemoveIron,"工具箱、搬运工具是否除铁");
                    // msg = msg + isChose(isCarryToolRemoveIron,"搬运工具除铁确认");
                    msg = msg + isChose(isOperatingPlatformRemoveIron,"操作平台是否除铁");
                    msg = msg + isChose(isOtherRemoveIron,"除铁器异物是否清理");

                    //msg = msg + isFillIn(envRemoveIronImgSrc,"环境除铁照片");

                    if(msg.length > 0){
                        alert(msg);
                    }else{
                        $.ajax({
                            async:false,
                            type:"POST",
                            url:"<?=base_url('XunJian_YiPei/addHJCTJLB')?>",
                            data:{
                                "userName": userName,
                                "userId": userId,
                                // "userDeptName": userDeptName,
                                "createTime": createTime,
                                "productLine": productLine,

                                "classes": classes,
                                "isGroundRemoveIron": isGroundRemoveIron,
                                // "isCornernRemoveIron": isCornernRemoveIron,
                                "isToolCaseRemoveIron": isToolCaseRemoveIron,
                                // "isCarryToolRemoveIron": isCarryToolRemoveIron,
                                "isOperatingPlatformRemoveIron": isOperatingPlatformRemoveIron,
                                "isOtherRemoveIron": isOtherRemoveIron,

                                // "envRemoveIronImgSrc": envRemoveIronImgSrc,

                            },
                            dataType:"json",
                            success:function(data){
                                var userid = $("#userId").val();
                                var hrefStr = "<?=base_url('XunJian_YiPei/submitSuccess?userid=')?>" + userid;
                                window.location.href = hrefStr;
                            },
                            error: function(XMLHttpRequest, textStatus, errorThrown) {
                                //alert(XMLHttpRequest.status);
                                //alert(XMLHttpRequest.readyState);
                                //alert(textStatus);
                                alert("您更新的信息有误，请重新确认或联系管理员！");
                            }
                        });
                    }

                })
                $("#back").click(function () {
                    var userid = $("#userId").val();
                    var hrefStr = "<?=base_url('XunJianChose/gotoindex?userid=')?>" + userid;
                    window.location.href = hrefStr;
                })
            })
            var checkClick = false;
            function NoClick() {
                if (checkClick == true) {
                    alert("提交中...请3秒后再点击");
                    return false;
                }
                checkClick = true;

                setTimeout(function() {
                        checkClick = false;
                    },
                    3000);
                return true;
            }
            /*
            判断输入的参数是否为数字
             */
            function myIsNaN(value) {
                return typeof value === 'number' && !isNaN(value);
            }
            /*
            判断信息是否已经输入
             */
            function isFillIn(value,msg) {
                var reMsg = "";
                if(value.length === 0){
                    reMsg = msg + "为必填！请填写输入" + msg + "!\n";
                }
                return reMsg;
            }
            /*
            判断信息是否已经选择
             */
            function isChose(value, msg) {
                var reMsg = "";
                if(typeof(value) === 'undefined'){
                    reMsg = msg + "为必选！请选择" + msg + "!\n";
                }
                return reMsg;
            }

        </script>
        <style type="text/css">
            .form-group{padding-top: 30px;}
        </style>
        <!-- HTML5 Shim 和 Respond.js 用于让 IE8 支持 HTML5元素和媒体查询 -->
        <!-- 注意： 如果通过 file://  引入 Respond.js 文件，则该文件无法起效果 -->
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
    </head>
    <div>
        <div class="container">
            <div style="margin-top: 0px;"></div>
            <div class="">
                <h1 style="text-align:center">一配
                    <small>环境除铁记录表</small>
                </h1>
            </div>
            <input type="hidden" name="userId" id="userId" value="<?=$userid?>">
            <input type="hidden" name="tableName" id="tableName" value="<?=$tableName?>" >
            <div class="form-group">
                <lable class="col-xs-5 span5 control-label">
                    填写人:
                </lable>
                <div class="input-group col-xs-7 span7">
                    <input type="text" class="form-control" rows="2" id="userName" name="userName" value="<?=$username?>" readonly>
                </div>
            </div>

<!--            <div class="form-group">-->
<!--                <lable class="col-xs-5 span5 control-label">-->
<!--                    所在部门:-->
<!--                </lable>-->
<!--                <div class="input-group col-xs-7 span7">-->
<!--                    <select class="userDeptName form-control" id="userDeptName" data-style="btn-primary" data-width="100%" title="请选择所在的部门">-->
<!--                        <option data-hidden="true" value="" disable>---请选择所在的部门---</option>-->
<!--                        <option value="部门一">部门一</option>-->
<!--                        <option value="部门二">部门二</option>-->
<!--                        <option value="部门三">部门三</option>-->
<!--                    </select>-->
<!---->
<!--                </div>-->
<!--            </div>-->

            <div class="form-group">
                <lable class="col-xs-5 span5 control-label">
                    填写时间:
                </lable>
                <div class="input-group col-xs-7 span7">
                    <?=date("Y-m-d H:i:s",$createTime)?>
                    <input type="hidden" class="form-control" rows="2" id="createTime" name="createTime" value="<?=$createTime?>" readonly="readonly">
                </div>
            </div>

            <div class="form-group">
                <lable class="col-xs-5 span5 control-label">
                    生产线名称:
                </lable>
                <div class="input-group col-xs-7 span7">
                    <select class="productLine form-control" id="productLine" data-style="btn-primary" data-width="100%" title="请选择生产线名称">
                        <option data-hidden="true" value="" disable>---请选择生产线名称---</option>
                        <?php foreach ($lineData as $value):?>
                            <option value="<?=$value['lineId']?>"><?=$value['lineName']?></option>
                        <?php endforeach;?>
                    </select>

                </div>
            </div>

            <div class="form-group">
                <lable class="col-xs-5 span5 control-label">
                    班次:
                </lable>
                <div id="classes" class="input-group col-xs-7 span7">
                    <label class="radio-inline">
                        <input type="radio" name="classes" value="1"> 白班
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="classes" value="0"> 夜班
                    </label>
                </div>
            </div>

            <div class="form-group">
                <lable class="col-xs-5 span5 control-label">
                    地面、墙角、墙边是否除铁:
                </lable>
                <div id="isGroundRemoveIron" class="input-group col-xs-7 span7">
                    <label class="radio-inline">
                        <input type="radio" name="isGroundRemoveIron" value="1"> 是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="isGroundRemoveIron" value="0"> 否
                    </label>
                </div>
            </div>

<!--            <div class="form-group">-->
<!--                <lable class="col-xs-5 span5 control-label">-->
<!--                    墙角、墙边除铁确认:-->
<!--                </lable>-->
<!--                <div id="isCornernRemoveIron">-->
<!--                    <label class="radio-inline">-->
<!--                        <input type="radio" name="isCornernRemoveIron" value="1"> 是-->
<!--                    </label>-->
<!--                    <label class="radio-inline">-->
<!--                        <input type="radio" name="isCornernRemoveIron" value="0"> 否-->
<!--                    </label>-->
<!--                </div>-->
<!--            </div>-->

            <div class="form-group">
                <lable class="col-xs-5 span5 control-label">
                    工具箱、搬运工具是否除铁:
                </lable>
                <div id="isToolCaseRemoveIron" class="input-group col-xs-7 span7">
                    <label class="radio-inline">
                        <input type="radio" name="isToolCaseRemoveIron" value="1"> 是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="isToolCaseRemoveIron" value="0"> 否
                    </label>
                </div>
            </div>

<!--            <div class="form-group">-->
<!--                <lable class="col-xs-5 span5 control-label">-->
<!--                    搬运工具除铁确认:-->
<!--                </lable>-->
<!--                <div id="isCarryToolRemoveIron">-->
<!--                    <label class="radio-inline">-->
<!--                        <input type="radio" name="isCarryToolRemoveIron" value="1"> 是-->
<!--                    </label>-->
<!--                    <label class="radio-inline">-->
<!--                        <input type="radio" name="isCarryToolRemoveIron" value="0"> 否-->
<!--                    </label>-->
<!--                </div>-->
<!--            </div>-->

            <div class="form-group">
                <lable class="col-xs-5 span5 control-label">
                    操作平台是否除铁:
                </lable>
                <div id="isOperatingPlatformRemoveIron" class="input-group col-xs-7 span7">
                    <label class="radio-inline">
                        <input type="radio" name="isOperatingPlatformRemoveIron" value="1"> 是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="isOperatingPlatformRemoveIron" value="0"> 否
                    </label>
                </div>
            </div>

            <div class="form-group">
                <lable class="col-xs-5 span5 control-label">
                    除铁器异物是否清理:
                </lable>
                <div id="isOtherRemoveIron" class="input-group col-xs-7 span7">
                    <label class="radio-inline">
                        <input type="radio" name="isOtherRemoveIron" value="1"> 是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="isOtherRemoveIron" value="0"> 否
                    </label>
                </div>
            </div>

<!--            <div class="form-group">-->
<!--                <lable class="col-xs-5 span5 control-label">-->
<!--                    环境除铁照片:-->
<!--                </lable>-->
<!--                <div class="input-group col-xs-7 span7">-->
<!--                    <input type="text" class="form-control" rows="2" id="envRemoveIronImgSrc" readonly="readonly" placeholder="请点击右侧按钮拍照并上传环境除铁照片">-->
<!--                    <span class="input-group-addon">-->
<!--                         <span class="glyphicon glyphicon-camera envRemoveIronImgSrc"> </span>-->
<!--                    </span>-->
<!--                </div>-->
<!--            </div>-->
<!---->
<!--            <div id="showBeforeImg"></div>-->
<!---->
<!--            <div class="form-group">-->
<!--                <lable class="col-xs-5 span5 control-label">-->
<!--                    清理后筛振照片:-->
<!--                </lable>-->
<!--                <div class="input-group col-xs-7 span7">-->
<!--                    <input type="text" class="form-control" rows="2" id="afterImgSrc" readonly="readonly" placeholder="请点击右侧按钮拍照并上传清理后筛振照片">-->
<!--                    <span class="input-group-addon">-->
<!--                             <span class="glyphicon glyphicon-camera afterImgSrc"> </span>-->
<!--                        </span>-->
<!--                </div>-->
<!--            </div>-->
<!---->
<!--            <div id="showAfterImg"></div>-->

            <div class="form-group">
                <button id="submit" type="button" class="btn btn-primary btn-lg btn-block">
                    提交
                </button>
            </div>
            <div class="form-group" style="padding-top: 5px">
                <button id="back" type="button" class="btn btn-primary btn-lg btn-block">
                    返回
                </button>
            </div>
            <!--
            <p>
                <button id="test" type="button" class="btn btn-primary btn-lg btn-block">
                    调用二维码扫描
                </button>
            </p>
            <hr>
            <p>
                <button id="choose" type="button" class="btn btn-primary btn-lg btn-block">
                    调用相册或者摄像头上传图片
                </button>
            </p>
            <hr>
            <p>
            <div id="showimg"></div>
            </p>
            -->
        </div>
    </div>
</div>
<!--
<hr>
<p>
    <button id="upload" type="button" class="btn btn-primary btn-lg btn-block">
       上传图片
    </button>
</p>
<hr>
<p>
    <button id="download" type="button" class="btn btn-primary btn-lg btn-block">
       下载图片
    </button>
</p>
-->
</body>
</html>